﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReadyApps.Models.Wiki
{
    class WikiPageText : IWikiPageComponent
    {
        #region Properties

        public string Text { get; private set; }

        #endregion

        #region Constructor

        public WikiPageText(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            Text = text;
        }

        #endregion

        #region Public Methods

        public Control GetControl()
        {
            return new Literal() { Text = this.Text };
        }

        public string GetMarkup()
        {
            return this.Text;
        }

        public override bool Equals(object other)
        {
            if (other is IWikiPageComponent)
            {
                return Equals((IWikiPageComponent)other);
            }
            else
            {
                return false;
            }
        }

        public bool Equals(IWikiPageComponent other)
        {
            if (other is WikiPageText)
            {
                return Equals((WikiPageText)other);
            }
            else
            {
                return false;
            }
        }

        public bool Equals(WikiPageText other)
        {
            if (other == null)
            {
                return false;
            }
            return Text.Equals(((WikiPageText)other).Text);
        }

        #endregion
    }
}
